<h1>测试表单</h1>
<form [formGroup]="myForm" (ngSubmit)="submit()">
  <table>
    <tr>
      <td>
        <label for="username">用户名：</label>
      </td>
      <td>
        <input type="text" id="username" formControlName="username">
      </td>
    </tr>

    <tr>
      <td>
        <label for="password">密码：</label>
      </td>
      <td>
        <input type="text" id="password" formControlName="password">
      </td>
    </tr>

    <ng-container formGroupName="address">
      <tr>
        <td>
          <label for="city">城市：</label>
        </td>
        <td>
          <input type="text" id="city" formControlName="city">
        </td>
      </tr>
      <tr>
        <td>
          <label for="street">街道：</label>
        </td>
        <td>
          <input type="text" id="street" formControlName="street">
        </td>
      </tr>
    </ng-container>

    <ng-container formArrayName="education">
      <tr *ngFor="let item of education.controls; let i = index">
        <ng-container [formGroupName]="i">
          <td>
            <ng-container *ngIf="i === 0">
              教育经历
            </ng-container>
          </td>
          <td>
            <input type="text" formControlName="school">
          </td>
          <td *ngIf="i === 0">
            <button type="button" (click)="addEducation()">添加</button>
          </td>
          <td *ngIf="i !== 0">
            <button type="button" (click)="removeEducation(i)">删除</button>
          </td>
        </ng-container>
      </tr>
    </ng-container>

    <tr>
      <td>
        <button type="submit" [disabled]="myForm.invalid">提交</button>
      </td>
    </tr>
  </table>
</form>
